package com.demo.hello.decoupling;

/**
 * 描述：
 *
 * @author lida
 * @time 2019/10/11 9:59
 */
public class StandardOutMessageRender implements MessageRenderer {
	private MessageProvider messageProvider;

	@Override
	public void render() {
		if (messageProvider == null){
			throw new RuntimeException("You forgot set the property messageProvider of class" +
					StandardOutMessageRender.class.getName());
		}
		System.out.println(messageProvider.getMessage());
	}

	@Override
	public void setMessageProvider(MessageProvider provider) {
		this.messageProvider = provider;
	}

	@Override
	public MessageProvider getMessageProvider() {
		return messageProvider;
	}
}
